<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt"  prefix="fmt" %>

<!DOCTYPE html>
<html>
<head>
	<title>景点信息显示</title>
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<!-- 引入bootstrap -->
	<link rel="stylesheet" type="text/css" href="<%=request.getContextPath()%>/css/bootstrap.min.css">

	<!-- 引入JQuery  bootstrap.js-->
	<script src="<%=request.getContextPath()%>/js/jquery-3.2.1.min.js"></script>
	<script src="<%=request.getContextPath()%>/js/bootstrap.min.js"></script>
	<%--<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">--%>
	<style type="text/css">
		.wrap{
			width: 80px;
			white-space: nowrap;
			text-overflow: ellipsis;
			overflow: hidden;
		}
	</style>
</head>
<body>
	<!-- 顶栏 -->
	<jsp:include page="top.jsp"></jsp:include>
	<!-- 中间主体 -->
	<div class="container" id="content">
		<div class="row">
			<jsp:include page="menu.jsp"></jsp:include>
			<div class="col-md-10">
				<div class="panel panel-default">
				    <div class="panel-heading">
						<div class="row">
					    	<h1 class="col-md-5">景点管理</h1>
							<form class="bs-example bs-example-form col-md-5" role="form" style="margin: 20px 0 10px 0;" action="<%=request.getContextPath()%>/admin/Scenery/selectScenery" id="sceneryForm" method="post">
								<div class="input-group">
									<input type="text" class="form-control" placeholder="请输入名称" name="sname">
									<span class="input-group-addon btn" id="sub">搜索</span>
								</div>
							</form>
							<button class="btn btn-default col-md-2" style="margin-top: 20px" onClick="location.href='<%=request.getContextPath()%>/admin/SceneryList/showSceneryList'">
								类别管理
								<sapn class="glyphicon glyphicon-asterisk"/>
							</button>
							<button class="btn btn-default col-md-2" style="margin-top: 20px" onClick="location.href='<%=request.getContextPath()%>/admin/Scenery/addScenery'">
								添加景点
								<sapn class="glyphicon glyphicon-plus"/>
							</button>
						</div>
				    </div>
				    <table class="table table-bordered wrap">
					        <thead>
					            <tr>
									<th>序号</th>
									<th>景点名称</th>
									<th>景点头像</th>
									<th>景点地址</th>
									<th>景点简介</th>
									<th>景点纬度</th>
									<th>景点经度</th>
									<th>图标高/宽</th>
<%--									<th>Marker图标</th>--%>
<%--									<th>景点展示图</th>--%>
									<th>景点热度</th>
									<th>景点所属</th>
									<th>操作</th>
					            </tr>
					        </thead>
					        <tbody>
							<c:forEach  items="${sceneryList}" var="item">
								<tr>
									<td width="50px">${item.id}</td>
									<td width="80px" class="wrap"> <div class="wrap" title="${item.sname}"> ${item.sname} </div></td>
									<td width="80px"><img width="80px" height="50px" id="images1" alt="景点头像" src="/image/${item.tximg }"></td>
									<td width="80px" class="wrap"> <div class="wrap" title="${item.floor}"> ${item.floor} </div> </td>
									<td width="80px" class="wrap"> <div class="wrap" title="${item.description}"> ${item.description} </div> </td>
									<td width="80px" class="wrap"> <div class="wrap" title="${item.latitude}"> ${item.latitude} </div></td>
									<td width="80px" class="wrap"> <div class="wrap" title="${item.longitude}"> ${item.longitude} </div></td>
									<td width="80px">${item.width}</td>
<%--									<td><img width="50px" height="50px" id="images" alt="景点头像" src="/image/${item.iconPath }"></td>--%>
<%--									<td><img width="50px" height="50px" id="images2" alt="景点展示图" src="/image/${item.img }"></td>--%>
									<td width="80px">${item.grade}</td>
									<td width="80px">${item.sceneryname}</td>
									<td width="90px">
										<button class="btn btn-default btn-xs btn-info" onClick="location.href='<%=request.getContextPath()%>/admin/Scenery/editScenery?id=${item.id}'">修改</button>
										<button class="btn btn-default btn-xs btn-danger btn-primary"
												onclick="remove('<%=request.getContextPath()%>/admin/Scenery/removeScenery?id=${item.id}')">删除</button>
										<!--弹出框-->
									</td>
								</tr>
							</c:forEach>
					        </tbody>
				    </table>
				    <div class="panel-footer">
						<c:if test="${pagingVO != null}">
							<nav style="text-align: center">
								<ul class="pagination">
									<li><a href="<%=request.getContextPath()%>/admin/Scenery/showScenery?page=${pagingVO.upPageNo}">&laquo;上一页</a></li>
									<li class="active"><a href="">${pagingVO.curentPageNo}</a></li>
									<c:if test="${pagingVO.curentPageNo+1 <= pagingVO.totalCount}">
										<li><a href="<%=request.getContextPath()%>/admin/Scenery/showScenery?page=${pagingVO.curentPageNo+1}">${pagingVO.curentPageNo+1}</a></li>
									</c:if>
									<c:if test="${pagingVO.curentPageNo+2 <= pagingVO.totalCount}">
										<li><a href="<%=request.getContextPath()%>/admin/Scenery/showScenery?page=${pagingVO.curentPageNo+2}">${pagingVO.curentPageNo+2}</a></li>
									</c:if>
									<c:if test="${pagingVO.curentPageNo+3 <= pagingVO.totalCount}">
										<li><a href="<%=request.getContextPath()%>/admin/Scenery/showScenery?page=${pagingVO.curentPageNo+3}">${pagingVO.curentPageNo+3}</a></li>
									</c:if>
									<c:if test="${pagingVO.curentPageNo+4 <= pagingVO.totalCount}">
										<li><a href="<%=request.getContextPath()%>/admin/Scenery/showScenery?page=${pagingVO.curentPageNo+4}">${pagingVO.curentPageNo+4}</a></li>
									</c:if>
									<li><a href="<%=request.getContextPath()%>/admin/Scenery/showScenery?page=${pagingVO.totalCount}">最后一页&raquo;</a></li>
								</ul>
							</nav>
						</c:if>
				    </div>
					<div class="panel-footer" style="text-align: center;">共${num}条记录</div>
				</div>
			</div>
		</div>
	</div>
	<div class="container" id="footer">
		<div class="row">
			<div class="col-md-12"></div>
		</div>
	</div>

	<!-- 信息删除确认 -->
	<div class="modal fade" id="removeScenery">
		<div class="modal-dialog">
			<div class="modal-content message_align">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal" aria-label="Close">
						<span aria-hidden="true">×</span>
					</button>
					<h4 class="modal-title">提示信息</h4>
				</div>
				<div class="modal-body">
					<p>您确认要删除此景点信息吗？</p>
				</div>
				<div class="modal-footer">
					<input type="hidden" id="url"/>
					<button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
					<a  onclick="urlSubmit()" class="btn btn-success" data-dismiss="modal">确定</a>
				</div>
			</div>
		</div>
	</div>
</body>
	<script type="text/javascript">
		$("#nav li:nth-child(3)").addClass("active")

		// 删除提示
		function remove(url) {
			$('#url').val(url);//给会话中的隐藏属性URL赋值
			$('#removeScenery').modal();
		}
		function urlSubmit(){
			var url=$.trim($("#url").val());//获取会话中的隐藏属性URL
			window.location.href=url;
		}

        <c:if test="${pagingVO != null}">
        if (${pagingVO.curentPageNo} == ${pagingVO.totalCount}) {
            $(".pagination li:last-child").addClass("disabled")
        };

        if (${pagingVO.curentPageNo} == ${1}) {
            $(".pagination li:nth-child(1)").addClass("disabled")
        };
        </c:if>

        $("#sub").click(function () {
            $("#sceneryForm").submit();
        });
	</script>
</html>